package order;

import goods.Goods;

public class Order {
    private long orderNumber;
    private Goods goods;
    private String time;
    private String userName;

    public Order(String orderNumber, Goods goods, String time, String userName) {
        this.orderNumber = Long.parseLong(orderNumber);
        this.goods = goods;
        this.time = time;
        this.userName = userName;
    }

    public long getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(long orderNumber) {
        this.orderNumber = orderNumber;
    }

    public Goods getGoods() {
        return goods;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Override
    public String toString() {
        StringBuilder str = new StringBuilder();
        str.append(orderNumber+" "+goods.getName()+" "+goods.getPrice()+" ");
        for (int i = 0 ; i < goods.getLabel().size() ; i ++ ) {
            if(i == 0 ) {
                str.append(goods.getLabel().get(i));
            }else {
                str.append("、"+goods.getLabel().get(i));
            }
        }
        str.append(" ").append(goods.getAmount()).append(" ").append(goods.getId()).append(" ").append(time).append(" ").append(userName);
        str.append("\n");
        String S = new String(str);
        return S;
    }
}
